package chpt06;

import java.util.Arrays;
import java.util.Scanner;

class ArrayUtils{
	public static double findMax(double[] arr,int begin, int end) throws IllegalArgumentException{
		if(begin>=end)
			throw new IllegalArgumentException("begin:"+begin+" >= end:"+end);
	    if(begin<0)
			throw new IllegalArgumentException("begin:"+begin+" < 0");
	    if(end>arr.length)
			throw new IllegalArgumentException("end:"+end+" > arr.length");
		Arrays.sort(arr, begin, end-1);
		return arr[end-1];
		
	}
}

public class YCMain3 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
      Scanner sc=new Scanner(System.in);
      int n=sc.nextInt();
      int begin,end;
      double arr[]=new double[n];
      for (int i = 0; i < arr.length; i++) {
		arr[i]=sc.nextDouble();
	}
      while(sc.hasNext()){ 
    	      try{
    		  String str1=sc.next();
    		  begin=Integer.parseInt(str1);
    		  String str2=sc.next();
    		  end=Integer.parseInt(str2); 
    		 
    	      }
    	      catch(NumberFormatException e){
    	    	  break;
    	      }
    	      try{
    	    	  double res=ArrayUtils.findMax(arr, begin, end);
    	    	  System.out.println(res);
    	      }
    	      catch(IllegalArgumentException e){
    	    	  System.out.println(e);
    	    	  continue;
    	      }
    	     
    	 
      }
      try {
    	     System.out.println(ArrayUtils.class.getDeclaredMethod("findMax", double[].class,int.class,int.class));
    	} catch (Exception e1) {
    	}
	}

}
